import QtQuick 1.1
import com.meego 1.0
import "Modulelib.js" as ModuleUtil
import "CommomUtil.js" as Util

Page {
    id: dealer_list_page

    tools: ModuleToolBar{}

    orientationLock : PageOrientation.LockPortrait

     TitleBar{
            id: module_detail_title
            anchors.top: dealer_list_page.top; anchors.left: dealer_list_page.left
            width: dealer_list_page.width; height: 71
            titleName: "经销商"
        }

    Rectangle{
        id: list_show_rect
        height: parent.height - 144
        anchors{left: parent.left; top: module_detail_title.bottom}
        FlickListView{
            id: list_show
            anchors.fill: parent
            model: list_show_data
            delegate: dealerDelegate
        }
    }


    Component{
        id: dealerDelegate
        Item{
            width: dealer_list_page.width; height: 148
            Rectangle{
                id: dealer_info
                anchors.fill: parent
                border{color: "#b0bdcf"; width: 1}
                Rectangle{
                    anchors{fill: parent; margins: 20}

                    Column{
                        spacing: 3
                        Text {
                            text: dealerName
                            font{bold: true; pointSize: 18}
                            color: "#000000"
                            horizontalAlignment: Text.AlignLeft
                        }
                        Row{
                            spacing: 5
                            Text{
                                text: "经销厂商:"
                                font{bold: true; pointSize: 14}
                                color: "#abb2b3"
                            }
                            Text{
                                text: dealerSimName
                                font{bold: true; pointSize: 16}
                                color: "#abb2b3"
                            }
                        }
                        Row{
                            spacing: 5
                            Text{
                                text: "公司地址:"
                                font{bold: true; pointSize: 14}
                                color: "#abb2b3"
                            }
                            Text{
                                text: dealerAddr
                                font{bold: true; pointSize: 16}
                                color: "#abb2b3"
                            }
                        }
                        Row{
                            spacing: 5
                            Text{
                                text: "公司电话:"
                                font{bold: true; pointSize: 14}
                                color: "#abb2b3"
                            }
                            Text{
                                text: dealerPhone
                                font{bold: true; pointSize: 16}
                                color: "#abb2b3"
                            }
                        }
                    }
                }
            }

            MouseArea{
                id: dealerInfoArea
                anchors.fill: parent
                onClicked: { // 经销商详细页面
                    ModuleUtil.current_dealer_id = dealerId;
                    ModuleUtil.current_dealer_name = dealerName;
                    Util.openFile("DealerInfoPage.qml");
                }
            }
            states: [
                State {
                    name: 'pressed'; when: dealerInfoArea.pressed
                    PropertyChanges { target: dealer_info; focus: true; opacity: 0.5}
                }
            ]
        }
    }



    ModuleDealerModel{
        id: list_show_data
    }

    BusyLoading{
        id: loading
        anchors.centerIn: parent
        visible:false
    }

    Component.onCompleted: {
        loading.loading();
        list_show_data.getData();
    }
}
